import requests
import app


class EmpAPI():

    # 初始化URL
    def __init__(self):
        self.addEmp_url = app.BASE_URL + "/api/sys/user"
        self.updateEmp_url = app.BASE_URL + "/api/sys/user/{}"
        self.getEmp_url = app.BASE_URL + "/api/sys/user/{}"
        self.deleteEmp_url = app.BASE_URL + "/api/sys/user/{}"

    # 添加员工 -
    def addEmp(self, emp_data):
        return requests.post(url=self.addEmp_url, json=emp_data, headers=app.HEADERS)

    # 修改员工 - id
    def updateEmp(self, emp_id, emp_data):
        url = self.updateEmp_url.format(emp_id)
        return requests.put(url=url, json=emp_data, headers=app.HEADERS)

    # 查询员工 - id
    def getEmp(self, emp_id):
        url = self.getEmp_url.format(emp_id)
        return requests.get(url=url,headers=app.HEADERS)

    # 删除员工 - id
    def deleteEmp(self, emp_id):
        url = self.deleteEmp_url.format(emp_id)
        return requests.delete(url=url,headers=app.HEADERS)
